2 Copyright (C) 2024 Rubén Beltrán del Río
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see https://map.tranquil.systems.
22 struct MapRenderView: View {
24 @Binding var document: MapDocument
25 @Binding var evolution: StageType
28 Stage.stages(evolution)
31 var parsedMap: ParsedMap {
32 MapParser.parse(content: document.text)
35 let mapSize = Dimensions.mapSize
36 let padding = Dimensions.mapPadding
38 let lineWidth = CGFloat(0.5)
39 let vertexSize = CGSize(width: 25.0, height: 25.0)
41 var onDragVertex: (Vertex, CGFloat, CGFloat) -> Void = { _, _, _ in }
44 ZStack(alignment: .topLeading) {
49 x: -padding, y: -padding, width: mapSize.width + padding * 2,
50 height: mapSize.height + padding * 4))
53 MapStages(mapSize: mapSize, lineWidth: lineWidth, stages: parsedMap.stages)
55 mapSize: mapSize, lineWidth: lineWidth, evolution: stage, stages: parsedMap.stages)
57 mapSize: mapSize, lineWidth: lineWidth, vertexSize: vertexSize, edges: parsedMap.edges)
58 MapBlockers(mapSize: mapSize, vertexSize: vertexSize, blockers: parsedMap.blockers)
60 mapSize: mapSize, vertexSize: vertexSize, vertices: parsedMap.vertices,
61 onDragVertex: onDragVertex)
63 mapSize: mapSize, lineWidth: lineWidth, vertexSize: vertexSize,
64 opportunities: parsedMap.opportunities)
65 MapGroups(mapSize: mapSize, vertexSize: vertexSize, groups: parsedMap.groups).drawingGroup(
69 mapSize: mapSize, lineWidth: lineWidth, notes: parsedMap.notes)
70 }.offset(x: padding, y: padding).frame(
71 width: mapSize.width + 2 * padding,
72 height: mapSize.height + 2 * padding, alignment: .topLeading
79 document: Binding.constant(MapDocument(text: "")),
80 evolution: Binding.constant(StageType.general)